package com.taiyuan.zfmvp.thread;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @param request
 * @Author: zhoufang@si-tech.com.cn
 * @Descriiption:
 * @Date 2022/3/5
 * @return
 */
public class ThreadPoolTest {
    public static void main(String[] args) {

        //阻塞队列
        ExecutorService pool = Executors.newFixedThreadPool(10);
        for(int i=0;i<15;i++){
            pool.execute(new Runnable() {
                @Override
                public void run() {

                    System.out.println(Thread.currentThread().getName()+" is running ");
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            });
        }
        pool.shutdown();
    }

}
